package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.userservice.parameter.LoginidexistsBean;
import com.ymatou.iapi.userservice.service.LoginidexistsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.JUserWapper;
/**
*查询登录ID是否存在
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Loginidexists{
	private static LoginidexistsBean loginidexistsBean;
	private static LoginidexistsCall loginidexistsCall;
	private static JUserWapper jUserWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询登录ID是否存在");
	}

	@Before
	public void caseUp() {
		loginidexistsBean=new LoginidexistsBean();
		loginidexistsCall=new LoginidexistsCall();
		jUserWapper=new JUserWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(loginidexistsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Loginidexis_001() {
		Logger.start(true,"输入的loginId存在,返回存在loginId");
		try {
			//获取loginId
			Userinfo model=jUserWapper.selectTop1Userinfo();
			loginidexistsBean.setLoginId(model.getLoginId());
			loginidexistsCall.setData(loginidexistsBean);
			loginidexistsCall.callService();
			Logger.verifyEquals("true", loginidexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("200", loginidexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("true", loginidexistsCall.getResultData().getResult().getLoginIdExists(), "验证存在loginId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_Loginidexis_002() {
		Logger.start(true,"输入的loginId不存,返回不存在loginId");
		try {
			loginidexistsBean.setLoginId("404NotFound");
			loginidexistsCall.setData(loginidexistsBean);
			loginidexistsCall.callService();
			Logger.verifyEquals("true", loginidexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("200", loginidexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("false", loginidexistsCall.getResultData().getResult().getLoginIdExists(), "验证存在loginId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_Loginidexis_003() {
		Logger.start(true,"不输入loginId,返回不存在loginId");
		try {
			//loginidexistsBean.setLoginId("");
			loginidexistsCall.setData(loginidexistsBean);
			loginidexistsCall.callService();
			Logger.verifyEquals("false", loginidexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("100", loginidexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_Loginidexis_004() {
		Logger.start(true,"输入的loginId为null,返回不存在loginId");
		try {
			loginidexistsBean.setLoginId(null);
			loginidexistsCall.setData(loginidexistsBean);
			loginidexistsCall.callService();
			Logger.verifyEquals("false", loginidexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("100", loginidexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}